﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace BoAddonBiz_FreightForwarder.ObjectFind
{
    enum FieldDataType { Int, String, DateTime, Enum }
    class ObjectFindLine : INotifyPropertyChanged, INotifyPropertyChanging
    {
        #region fields
        private string _TableName;
        private string _Field;
        private string _FieldName;
        private string _Alias;
        private FieldDataType _DataType;
        private bool _IsFind;
        private bool _IsDisplay;
        private bool _Master;
        private int _SizeId;
        private FieldAlternates _Alternates;
        #endregion
        #region constructor
        public ObjectFindLine()
        {
            _Alternates = new FieldAlternates();
        }
        #endregion
        #region propreties
        public string TableName
        {
            get { return _TableName; }
            set
            {
                if (_TableName != value)
                {
                    OnPropertyChanging("TableName");
                    _TableName = value;
                    OnPropertyChanged("TableName");
                }
            }
        }
        public string Field
        {
            get { return _Field; }
            set
            {
                if (_Field != value)
                {
                    OnPropertyChanging("Field");
                    _Field = value;
                    OnPropertyChanged("Field");
                }
            }
        }
        public string FieldName
        {
            get { return _FieldName; }
            set
            {
                if (_FieldName != value)
                {
                    OnPropertyChanging("FieldName");
                    _FieldName = value;
                    OnPropertyChanged("FieldName");
                }
            }
        }
        public string Alias
        {
            get { return _Alias; }
            set
            {
                if (_Alias != value)
                {
                    OnPropertyChanging("Alias");
                    _Alias = value;
                    OnPropertyChanged("Alias");
                }
            }
        }
        public FieldDataType DataType
        {
            get { return _DataType; }
            set
            {
                if (_DataType != value)
                {
                    OnPropertyChanging("DataType");
                    _DataType = value;
                    OnPropertyChanged("DataType");
                }
            }
        }
        public bool IsFind
        {
            get { return _IsFind; }
            set
            {
                if (_IsFind != value)
                {
                    OnPropertyChanging("IsFind");
                    _IsFind = value;
                    OnPropertyChanged("IsFind");
                }
            }
        }
        public bool IsDisplay
        {
            get { return _IsDisplay; }
            set
            {
                if (_IsDisplay != value)
                {
                    OnPropertyChanging("IsDisplay");
                    _IsDisplay = value;
                    OnPropertyChanged("IsDisplay");
                }
            }
        }
        public bool Master
        {
            get { return _Master; }
            set
            {
                if (_Master != value)
                {
                    OnPropertyChanging("Master");
                    _Master = value;
                    OnPropertyChanged("Master");
                }
            }
        }
        public int SizeId
        {
            get { return _SizeId; }
            set
            {
                if (_SizeId != value)
                {
                    OnPropertyChanging("SizeId");
                    _SizeId = value;
                    OnPropertyChanged("SizeId");
                }
            }
        }
        public FieldAlternates Alternates
        {
            get { return _Alternates; }
        }
        #endregion
        #region methods
        private void OnPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }
        private void OnPropertyChanging(string PropertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(PropertyName));
            }
        }
        #endregion
        #region events
        public event PropertyChangedEventHandler PropertyChanged;
        public event PropertyChangingEventHandler PropertyChanging;
        #endregion
    }
    class FieldAlternate
    {
        public int Index { get; set; }
        public string Value { get; set; }
        public string Descr { get; set; }
    }
    class FieldAlternates : List<FieldAlternate>
    {
        public FieldAlternate Add()
        {
            FieldAlternate oField = new FieldAlternate();
            this.Add(oField);
            return oField;
        }
    }
}
